﻿using System;
using System.Net.Mail;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using MammothMicro.SmtpGuardFilter;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SmtpGuardTest
{
    [TestClass]
    public class ToolsTest
    {
        [TestMethod]
        public void ExtractIpTest()
        {
            var msg = new MailMessage();
            msg.Headers.Add(@"Received",@"from by2acnmsa01.alerts.live.com (207.46.117.142) by EXCHANGE2010.MammothMicro.local (192.168.10.227) with Microsoft SMTP Server id 14.0.639.21; Thu, 26 Nov 2009 08:33:23 -0800");
            msg.Headers.Add(@"Received",@"from mail pickup service by by2acnmsa01.alerts.live.com with Microsoft SMTPSVC; Thu, 26 Nov 2009 08:34:13 -0800");
            var ip =  Tools.ExtractIp(msg);
            Assert.IsTrue(ip.Count() == 1);
            var ips = Tools.ExtractIp(msg, false);
            Assert.IsTrue(ips.Count() == 2);

        }
    }
}
